Skip to content

api: add zone, vm name params in listVmSnapshot response#4604

Merged
yadvr merged 4 commits intoapache:4.15from
shapeblue:add-name-params-listvmsnapshots
Feb 19, 2021
Merged

api: add zone, vm name params in listVmSnapshot response#4604
yadvr merged 4 commits intoapache:4.15from
shapeblue:add-name-params-listvmsnapshots

Conversation

@shwstppr
Copy link
Contributor

Description

Adds new params in listVmSnapshot API - zonename, virtualmachinename

Fixes #4603

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

UI
After change zone name and VM name are shown
Screenshot from 2021-01-20 17-52-47

CMK:
Before -

> list vmsnapshot vmsnapshotid=db83c1a7-7870-442d-8c27-d9d407a05f11
{
  "count": 1,
  "vmSnapshot": [
    {
      "account": "admin",
      "created": "2021-01-20T17:34:35+0530",
      "current": true,
      "displayname": "vm-snap",
      "domain": "ROOT",
      "domainid": "52611b65-5b16-11eb-b67a-645d8651f45a",
      "hypervisor": "Simulator",
      "id": "db83c1a7-7870-442d-8c27-d9d407a05f11",
      "name": "i-2-3-VM_VS_20210120120435",
      "state": "Ready",
      "tags": [],
      "type": "Disk",
      "virtualmachineid": "3a07d2d4-18ad-4ef4-ac97-7937ba629069",
      "zoneid": "5918c672-47aa-4425-9ff9-d71d79d2b304",
    }
  ]
}

After-

> list vmsnapshot vmsnapshotid=db83c1a7-7870-442d-8c27-d9d407a05f11
{
  "count": 1,
  "vmSnapshot": [
    {
      "account": "admin",
      "created": "2021-01-20T17:34:35+0530",
      "current": true,
      "displayname": "vm-snap",
      "domain": "ROOT",
      "domainid": "52611b65-5b16-11eb-b67a-645d8651f45a",
      "hypervisor": "Simulator",
      "id": "db83c1a7-7870-442d-8c27-d9d407a05f11",
      "name": "i-2-3-VM_VS_20210120120435",
      "state": "Ready",
      "tags": [],
      "type": "Disk",
      "virtualmachineid": "3a07d2d4-18ad-4ef4-ac97-7937ba629069",
      "virtualmachinename": "test-vm",
      "zoneid": "5918c672-47aa-4425-9ff9-d71d79d2b304",
      "zonename": "Sandbox-simulator"
    }
  ]
}

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr shwstppr added this to the 4.15.1.0 milestone Jan 20, 2021
@shwstppr shwstppr self-assigned this Jan 20, 2021
@shwstppr shwstppr changed the title api: add zone, vm name params in listVmSnaphots response api: add zone, vm name params in listVmSnaphot response Jan 20, 2021
@shwstppr shwstppr changed the title api: add zone, vm name params in listVmSnaphot response api: add zone, vm name params in listVmSnapshot response Jan 20, 2021
@blueorangutan
Copy link

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2555

Copy link
Member

@harikrishna-patnala harikrishna-patnala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
if (vm != null) {
vmSnapshotResponse.setVirtualMachineid(vm.getUuid());
vmSnapshotResponse.setVirtualMachineId(vm.getUuid());
vmSnapshotResponse.setVirtualMachineName(vm.getHostName());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think display_name should be first choice, if it is null then we can go with host_name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @shwstppr, looks good to me now

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@apache apache deleted a comment from blueorangutan Jan 21, 2021
@apache apache deleted a comment from blueorangutan Jan 21, 2021
@sureshanaparti
Copy link
Contributor

sureshanaparti commented Jan 21, 2021

@shwstppr I do understand that it is good to display name(s) of resources/entities in the UI. But, I think, to change the respective API responses to include the name(s) of the required resources/entities (to show in the UI) may not be the right thing. The UUIDs can be further used with the list API(s) to get the required details (name, zone, etc) to fill the UI as desired.

If we continue this exercise to show name(s) in the UI, finally we end up adding name(s) to most of the responses.

I know UI has to attempt multiple API calls, but API responses should primarly return UUIDs. For names and other details, make use of list API calls.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2562

@yadvr
Copy link
Member

yadvr commented Jan 21, 2021

@shwstppr is this for 4.15 or master, pl change base branch or milestone

@shwstppr shwstppr changed the base branch from master to 4.15 January 21, 2021 12:59
@shwstppr
Copy link
Contributor Author

@rhtyd sorry for the error. Changed the base branch

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@shwstppr
Copy link
Contributor Author

@shwstppr I do understand that it is good to display name(s) of resources/entities in the UI. But, I think, to change the respective API responses to include the name(s) of the required resources/entities (to show in the UI) may not be the right thing. The UUIDs can be further used with the list API(s) to get the required details (name, zone, etc) to fill the UI as desired.

If we continue this exercise to show name(s) in the UI, finally we end up adding name(s) to most of the responses.

I know UI has to attempt multiple API calls, but API responses should primarly return UUIDs. For names and other details, make use of list API calls.

@sureshanaparti I may agree with you on that partly but changes aren't causing any additional db query, plus we have similar parameters in other api responses so maybe this can be allowed ;)
Calling list api just for names in UI will be an overkill

@apache apache deleted a comment from blueorangutan Jan 21, 2021
@blueorangutan
Copy link

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2568

@harikrishna-patnala
Copy link
Member

@shwstppr I do understand that it is good to display name(s) of resources/entities in the UI. But, I think, to change the respective API responses to include the name(s) of the required resources/entities (to show in the UI) may not be the right thing. The UUIDs can be further used with the list API(s) to get the required details (name, zone, etc) to fill the UI as desired.
If we continue this exercise to show name(s) in the UI, finally we end up adding name(s) to most of the responses.
I know UI has to attempt multiple API calls, but API responses should primarly return UUIDs. For names and other details, make use of list API calls.

@sureshanaparti I may agree with you on that partly but changes aren't causing any additional db query, plus we have similar parameters in other api responses so maybe this can be allowed ;)
Calling list api just for names in UI will be an overkill

Agree with you @shwstppr

@shwstppr
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@shwstppr a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@sureshanaparti
Copy link
Contributor

sureshanaparti commented Jan 22, 2021

@shwstppr I do understand that it is good to display name(s) of resources/entities in the UI. But, I think, to change the respective API responses to include the name(s) of the required resources/entities (to show in the UI) may not be the right thing. The UUIDs can be further used with the list API(s) to get the required details (name, zone, etc) to fill the UI as desired.
If we continue this exercise to show name(s) in the UI, finally we end up adding name(s) to most of the responses.
I know UI has to attempt multiple API calls, but API responses should primarly return UUIDs. For names and other details, make use of list API calls.

@sureshanaparti I may agree with you on that partly but changes aren't causing any additional db query, plus we have similar parameters in other api responses so maybe this can be allowed
Calling list api just for names in UI will be an overkill

@shwstppr So, do you mean it is the right approach to consider the API response object parameters for UI display? Few recent PRs below, with such changes where the response parameters are mainly updated for UI display only, and I'm sure this will repeat to replace most of the UUID displayed in the UI for the names. :-)

#4483 - updated listNetworks API response for VPC Name
#4275 - updated listVmSnapshot API response for Hypervisor
#4073 - updated listPublicIpAddress API response for Network Name

@sureshanaparti
Copy link
Contributor

sureshanaparti commented Jan 22, 2021

@shwstppr May be some generic approach for the API response objects, to tag both UUID and Name (wherever UUID is returned) might work for all the APIs, and the names can be used appropriately in the UI when required.

@blueorangutan
Copy link

Trillian test result (tid-3408)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 35127 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4604-t3408-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_clusters.py
Smoke tests completed. 85 look OK, 1 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
test_07_deploy_kubernetes_ha_cluster Failure 3619.44 test_kubernetes_clusters.py
test_08_deploy_and_upgrade_kubernetes_ha_cluster Failure 0.05 test_kubernetes_clusters.py
test_09_delete_kubernetes_ha_cluster Failure 0.04 test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardown Error 64.07 test_kubernetes_clusters.py

@harikrishna-patnala
Copy link
Member

@shwstppr May be some generic approach for the API response objects, to tag both UUID and Name (wherever UUID is returned) might work for all the APIs, and the names can be used appropriately in the UI when required.

@sureshanaparti I get your proposal, but that I think it needs significant amount of changes as Name is not part of common interfaces (which I think is required for a generic approach) and it is defined as different names for each resource.

May be an another improvement ticket would help this PR to get continued !

@yadvr
Copy link
Member

yadvr commented Jan 25, 2021

@blueorangutan ui

1 similar comment
@yadvr
Copy link
Member

yadvr commented Jan 25, 2021

@blueorangutan ui

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@yadvr
Copy link
Member

yadvr commented Jan 25, 2021

@blueorangutan ui

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@blueorangutan
Copy link

UI build: ✔️
Live QA URL: http://primate-qa.cloudstack.cloud:8080/client/pr/4604 (JID-3829)

vmSnapshotResponse.setVirtualMachineid(vm.getUuid());
vmSnapshotResponse.setVirtualMachineId(vm.getUuid());
vmSnapshotResponse.setVirtualMachineName(Strings.isNullOrEmpty(vm.getDisplayName()) ? vm.getHostName() : vm.getDisplayName());
vmSnapshotResponse.setVirtualMachineName(vm.getHostName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is setVirtualMachineName() added twice @shwstppr ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhtyd that was by mistake in my previous commit 🤦 . Fixed it

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2686

if (vm != null) {
vmSnapshotResponse.setVirtualMachineid(vm.getUuid());
vmSnapshotResponse.setVirtualMachineId(vm.getUuid());
vmSnapshotResponse.setVirtualMachineName(Strings.isNullOrEmpty(vm.getDisplayName()) ? vm.getHostName() : vm.getDisplayName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we need one check if for normal user/account it leaks the internal hostname (is hostname the i-x-y-VM?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked hostname would return name from the Db table, lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uuids instead of display names are shown in detail view of VM snapshot

5 participants